package com.cf.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cf.domain.pojo.TeamOrder;
import com.cf.domain.vo.TeamOrderVO;
import com.cf.domain.vo.TeamOrdersVO;
import com.cf.mapper.TeamOrderMapper;
import com.cf.mapper.UserMapper;
import com.cf.service.ITeamOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author lzqinga@126.com
 * @Date 2024/11/12  19:42
 */
@Service
@RequiredArgsConstructor
public class TeamOrderServiceImpl extends ServiceImpl<TeamOrderMapper, TeamOrder> implements ITeamOrderService {

    private final TeamOrderMapper teamOrderMapper;
    @Override
    public List<TeamOrderVO> getTeamOrderByGroundId(Long groundId) {
        return teamOrderMapper.getListByGroundId(groundId);
    }

    @Override
    public boolean saveList(TeamOrdersVO teamOrdersVO) {
        List<TeamOrder> list = new ArrayList<>();
        for(Long id:teamOrdersVO.getIds()){
            TeamOrder teamOrder = new TeamOrder();
            teamOrder.setGroundId(teamOrdersVO.getGroundId());
            teamOrder.setUserId(id);
            teamOrder.setSort(Math.toIntExact(id));
            list.add(teamOrder);
        }
        return saveBatch(list);
    }

    @Override
    public List<TeamOrderVO> getListByUserId(Long userId) {
        return null;
    }

}
